{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " vtkplotter 2019.3.5  | vtk 8.1.2 | python 3.6 | press h for help. \n"
     ]
    }
   ],
   "source": [
    "###########################################################\n",
    "# Quick tutorial. Check out more examples in directories:\n",
    "#\texamples/basic \n",
    "#\texamples/advanced\n",
    "#\texamples/volumetric\n",
    "#\texamples/simulations\n",
    "#\texamples/other\n",
    "\n",
    "from vtkplotter import *\n",
    "############################################################\n",
    "# Caveat: in notebooks the rendering backend is K3D, so\n",
    "# some of the features are disabled wrt the python scripts.\n",
    "# Uncomment:\n",
    "embedWindow(False) #to pop an external VTK rendering window\n",
    "# In a VTK rendering window press:\n",
    "# q, to return to the notebook (window becomes unresponsive)\n",
    "# type interactive() to return to window interaction\n",
    "# type closeWindow() to close the rendering window\n",
    "############################################################\n",
    "\n",
    "# Declare an instance of the class\n",
    "vp = Plotter()\n",
    "\n",
    "# Load a vtk file as a Actor(vtkActor) and visualize it.\n",
    "# (The actual mesh corresponds to the outer shape of an embryonic mouse limb at about 11 days of gestation).\n",
    "vp.load(datadir+\"270.vtk\").c(\"aqua\")\n",
    "vp.show()  # picks what is automatically stored in python list vp.actors\n",
    "\n",
    "######## Press now q in window to return to the script #########\n",
    "\n",
    "vp.close() # (only necessary for the vtk backend) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loaded vtkActors:  3\n",
      " vtkplotter 2019.3.5  | vtk 8.1.2 | python 3.6 | press h for help. \n"
     ]
    }
   ],
   "source": [
    "#########################################################################################\n",
    "# Load 3 actors assigning each a different color,\n",
    "# by default use their file names as legend entries.\n",
    "# No need to use any variables, as actors are stored internally in list vp.actors:\n",
    "vp = Plotter()\n",
    "vp.load(datadir+\"250.vtk\", c=(1, 0.4, 0), alpha=0.3) # color is given here as (r,g,b)\n",
    "vp.load(datadir+\"270.vtk\", c=(1, 0.6, 0), alpha=0.2)\n",
    "vp.load(datadir+\"290.vtk\", c=(1, 0.8, 0), alpha=0.1)\n",
    "print(\"Loaded vtkActors: \", len(vp.actors))\n",
    "vp.show()\n",
    "vp.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " vtkplotter 2019.3.5  | vtk 8.1.2 | python 3.6 | press h for help. \n"
     ]
    }
   ],
   "source": [
    "#########################################################################################\n",
    "# Draw a spline through a set of points:\n",
    "from random import gauss, uniform as u\n",
    "vp = Plotter()\n",
    "\n",
    "pts = [(u(0, 2), u(0, 2), u(0, 2) + i) for i in range(8)]  # build python list of points\n",
    "vp += Points(pts, r=5) # add the actor points to the internal list of actors to be shown                                 # create the vtkActor\n",
    "\n",
    "for i in range(10):\n",
    "    sp = spline(pts, smooth=i/10.0, degree=2).color(i)\n",
    "    sp.legend(\"smoothing \" + str(i/10.0))\n",
    "    vp += sp\n",
    "vp.show(axes=1)  # show internal list of actors\n",
    "vp.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " vtkplotter 2019.3.5  | vtk 8.1.2 | python 3.6 | press h for help. \n"
     ]
    }
   ],
   "source": [
    "#########################################################################################\n",
    "# Increase the number of points in a mesh using subdivide()\n",
    "vp = Plotter()\n",
    "a1 = vp.load(datadir+\"beethoven.ply\")\n",
    "\n",
    "a2 = a1.clone().subdivide()  # make a copy and increase the number of points of the mesh\n",
    "vp.show(a1, a2.addPos([10,0,0]))\n",
    "vp.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " vtkplotter 2019.3.5  | vtk 8.1.2 | python 3.6 | press h for help. \n"
     ]
    }
   ],
   "source": [
    "#########################################################################################\n",
    "# Cut a set of shapes with a plane that goes through point at x=500 with normal (0,0.3,-1).\n",
    "# Wildcards can be used to load multiple files or entire directories:\n",
    "vp = Plotter()\n",
    "vp.load(datadir+\"2*0.vtk\")\n",
    "for i,a in enumerate(vp.actors):\n",
    "    a.color(i).cutWithPlane(origin=(500,0,0), normal=(0,0.3,-1))\n",
    "vp.show()\n",
    "vp.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
